feat: Add --allow-invalid-content-type-endpoint option to validate-json - #932
Merged
DannyvdSluijs merged 3 commits intoSep 1, 2026
Conversation
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
DannyvdSluijs
requested changes
Aug 14, 2026
DannyvdSluijs
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the addition. This is a good improvement, going through the changes I've made some comments to fix some small issues being introduced.
Can you take a look?
Contributor
Author
|
@DannyvdSluijs Thanks for the review. I pushed new commits fixing the highlighted issues. |
DannyvdSluijs
approved these changes
Sep 1, 2026
The validate-json CLI now accepts a repeatable `--allow-invalid-content-type-endpoint=<url>` option. Each URL prefix is registered on the UriRetriever via the existing `addInvalidContentTypeEndpoint()` API, bypassing the schema media type check for schemas fetched from that host. WordPress's `theme.json` uses `https://schemas.wp.org/trunk/theme.json` as its JSON schema (docs here: https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/). That URL redirects to `https://raw.githubusercontent.com/WordPress/gutenberg/trunk/schemas/json/theme.json`, which serves `Content-Type: text/plain; charset=utf-8`, so running `vendor/bin/validate-json theme.json https://schemas.wp.org/trunk/theme.json` failed with `InvalidSchemaMediaTypeException`. With the included changes, passing `--allow-invalid-content-type-endpoint=https://schemas.wp.org/` whitelists the requested host and lets the validation run.
Accept the value in both --option=value and --option value forms. Exit with a non-zero code when the value is missing instead of silently ignoring an empty value. Add CLI coverage for the option.
DannyvdSluijs
force-pushed
the
feature/env-for-invalid-content-type-endpoints
branch
from
September 1, 2026 17:26
fa0d555 to
281a878
Compare
DannyvdSluijs
added a commit
that referenced
this pull request
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
validate-jsonCLI now accepts a repeatable--allow-invalid-content-type-endpoint=<url>option. Each URL prefix is registered on the UriRetriever via the existingaddInvalidContentTypeEndpoint()method, bypassing the schema media type check for schemas fetched from that host.Related Issue
N/A
Type of Change
Checklist
Additional Notes
Example use case:
WordPress's
theme.jsonuseshttps://schemas.wp.org/trunk/theme.jsonas its JSON schema (docs here: https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/). That URL redirects tohttps://raw.githubusercontent.com/WordPress/gutenberg/trunk/schemas/json/theme.json, which servesContent-Type: text/plain; charset=utf-8, so runningfails with
InvalidSchemaMediaTypeException.With the included changes, passing
--allow-invalid-content-type-endpoint=https://schemas.wp.org/whitelists the requested host and lets the validation run.